package com.diary.server.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.diary.server.entity.Des;
import com.diary.server.entity.DiaryList;
import com.diary.server.mapper.DesMapper;
import com.diary.server.service.DesService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.List;
@Service
@Slf4j
public class DesServiceImpl extends ServiceImpl<DesMapper, Des> implements DesService {

    @Autowired
    private DesMapper desMapper;

    public List<Des> getWeeklyDiaries(Long userId, LocalDate startDate, LocalDate endDate) {
        return list(new QueryWrapper<Des>()
                .eq("user_id", userId)
                .ge("record_time", startDate.atStartOfDay())
                .le("record_time", endDate.atTime(23, 59, 59))
                .orderByAsc("record_time"));
    }

}
